<?php
// +----------------------------------------------------------------------
// | QSCMS
// +----------------------------------------------------------------------
// | Copyright (c)  2025 https://www.qqss.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed QSCMS is not free software, commercial use must purchase official license from official website to avoid unnecessary legal disputes.
// +----------------------------------------------------------------------
// | Author: Contract 990504246@qq.com
// +----------------------------------------------------------------------

namespace app\common\model;

use think\Model;

/**
 * 系统升级日志模型 该模型已废弃
 */
class UpgradeLog extends Model
{
    // 设置表名
    protected $name = 'upgrade_log';

    // 自动写入时间戳
    protected $autoWriteTimestamp = true;
    protected $updateTime = false; // 不需要更新时间

    /**
     * 获取类型列表
     */
    public static function getTypeList()
    {
        return [
            'check'    => '检查更新',
            'download' => '下载升级包',
            'verify'   => '验证升级包',
            'backup'   => '备份系统',
            'upgrade'  => '系统升级',
            'restore'  => '恢复系统'
        ];
    }

    /**
     * 获取状态列表
     */
    public static function getStatusList()
    {
        return [
            0 => '失败',
            1 => '成功'
        ];
    }

    /**
     * 获取类型文本
     */
    public function getTypeTextAttr($value, $data)
    {
        $typeList = self::getTypeList();
        return $typeList[$data['type']] ?? $data['type'];
    }

    /**
     * 获取状态文本
     */
    public function getStatusTextAttr($value, $data)
    {
        $statusList = self::getStatusList();
        return $statusList[$data['status']] ?? '未知';
    }
}